using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Freeform;


namespace Space_in_Shaders
{

    public class RadialCollision : CollisionGeometry
    {

        public const Byte CID_PLAYERSHIP = 0;
        public const Byte CID_AISHIP = 1;
        public const Byte CID_LASER = 2;
        public const Byte CID_GENERIC = 3;
        public const Byte CID_MISSILE = 4;

        public Single Radius { get; set; }

        public RadialCollision(Entity Ent, Single Radius)
            : base(Ent)
        {
            this.Radius = Radius;
        }


        public override bool CheckCollision(CollisionGeometry other)
        {
            RadialCollision Other = other as RadialCollision;

            if (Other == null) return base.CheckCollision(other);

            Single DistSquared = (Entity.SpatialProperties.Position - Other.Entity.SpatialProperties.Position).LengthSquared();
            Single Radii = Radius + Other.Radius;

            if (Radii * Radii > DistSquared)
                return true;

            return false;
        }
    }
}
